import Vue from 'vue'
import VueRouter from 'vue-router'
import Map from "../views/Map";
import Main from "../views/Main"
import Data from "../views/Data";


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/Map'
  },
  {
    path: '/main',
    component: Main,
    redirect: '/map',
    children: [
      { path: '/map', component: Map },
      { path: '/Data', component: Data }
    ]
  }
]

const router = new VueRouter({
  routes
})

// 挂载路由导航守卫

// router.beforeEach((to, from, next) => {
//   const strtoken = localStorage.getItem('token')
//   if (strtoken) {
//     next()
//   } else {
//     if (to.path === '/login') {
//       next()
//     } else {
//       next('/login')
//     }
//   }
// })

export default router
